What is a predicate, and how can you build a complex predicate out of
multiple simpler predicates?Show Answer
A predicate is a function that always returns a boolean value. To build a
complex predicate from simple ones, the complex predicate function should
call the simple functions and combine their result values using boolean
operators into a single boolean that it can return.
What is the difference between writing a series of if statements and a
single if statement with multiple elif parts?Show Answer
A series of if statements operate independently, and it's possible for
more than one to trigger. A chain of if/elif statements guarantees that
only the first statement whose condition is true will trigger, and others
will be skipped even if their conditions are also true.